//
//  UIView+Ext.m
//  分享demo
//
//  Created by pc-chtypd056 on 2018/8/22.
//  Copyright © 2018年 CTL. All rights reserved.
//

#import "UIView+Ext.h"

@implementation UIView (Ext)

- (void)setPoint:(CGPoint)point{
    CGRect rect = self.frame;
    rect.origin = point;
    self.frame = rect;
}

- (CGPoint)point{
    return self.frame.origin;
}

- (void)setSize:(CGSize)size{
    CGRect rect = self.frame;
    rect.size = size;
    self.frame = rect;
}

- (CGSize)size{
    return self.frame.size;
}

- (void)setHeight:(CGFloat)height{
    CGRect rect = self.frame;
    rect.size.height = height;
    self.frame = rect;
}

- (CGFloat)height{
    return self.frame.size.height;
}

- (void)setWidth:(CGFloat)width{
    CGRect rect = self.frame;
    rect.size.width = width;
    self.frame = rect;
}

- (CGFloat)width{
    return self.frame.size.width;
}

- (void)setTop:(CGFloat)top{
    CGRect rect = self.frame;
    rect.origin.y = top;
    self.frame = rect;
}

- (CGFloat)top{
    return self.frame.origin.y;
}

- (void)setBottom:(CGFloat)bottom{
    CGRect rect = self.frame;
    rect.origin.y = bottom - rect.size.height;
    self.frame = rect;
}

- (CGFloat)bottom{
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setLeft:(CGFloat)left{
    CGRect rect = self.frame;
    rect.origin.x = left;
    self.frame = rect;
}

- (CGFloat)left{
    return self.frame.origin.x;
}

- (void)setRight:(CGFloat)right{
    CGRect rect = self.frame;
    rect.origin.y = right - rect.size.width;
    self.frame = rect;
}

- (CGFloat)right{
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setCenterX:(CGFloat)centerX{
    self.center = CGPointMake(centerX, self.center.y);
}

- (CGFloat)centerX{
    return self.center.x;
}

- (void)setCenterY:(CGFloat)centerY{
    self.center = CGPointMake(self.center.y, centerY);
}

- (CGFloat)centerY{
    return self.center.y;
}

- (void)setX:(CGFloat)x{
    CGRect rect = self.frame;
    rect.origin.x = x;
    self.frame = rect;
}

- (CGFloat)x{
    return self.frame.origin.x;
}

- (void)setY:(CGFloat)y{
    CGRect rect = self.frame;
    rect.origin.y = y;
    self.frame = rect;
}

- (CGFloat)y{
    return self.frame.origin.y;
}

#pragma mark - -
- (void)addLineWithFrame:(CGRect)rect color:(UIColor *)color{
    UIView *line = [[UIView alloc]initWithFrame:rect];
    line.backgroundColor = color;
    [self addSubview:line];
}

@end
